let path = require("path");
let resolvePath = path.join(__dirname, "./src/style/var.less");

let baseUrl = {
  7006: "http://2.142.133.31:7006",
  5041: "http://2.142.133.142:5041",
};

let proxy = {
  "/7006": {
    target: baseUrl["7006"], // 后台接口域名
    changeOrigin: true, //是否跨域
    pathRewrite: {
      "^/7006": "/",
    },
  },
  "/5041": {
    target: baseUrl["5041"], // 后台接口域名
    changeOrigin: true, //是否跨域
    pathRewrite: {
      "^/5041": "/",
    },
  },
};

module.exports = {
  lintOnSave: true,
  devServer: { proxy },
  publicPath: "",
  chainWebpack: (config) => {
    config.plugin("html").tap((args) => {
      args[0].title = "盐城手机端领导驾驶舱";
      return args;
    });
  },
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true, //允许链式调用的换行
        modifyVars: {
          // 或者可以通过 less 文件覆盖（文件路径为绝对路径）
          hack: `true; @import "${resolvePath}";`,
        },
      },
      postcss: {
        plugins: [
          require("postcss-pxtorem")({
            rootValue: 37.5,
            propList: ["*"],
          }),
        ],
      },
    },
  },
};
